#!/bin/bash
error=0
for k in $(seq 1 3)
do
   if ! killall -0 haproxy &> /dev/null; then
       error=$(expr $error + 1)
       sleep 1
       continue
   else
       error=0
       break
   fi
done

if [[ $error != "0" ]]; then
   echo "systemctl stop keepalived"
   /usr/bin/systemctl stop keepalived
   exit 1
else
   exit 0
fi
